package aimis.controller;


import aimis.dto.Res;
import aimis.util.OssFile;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.UUID;

@RestController
@RequestMapping("/file")
public class UploadFileController {

    //上传图片接口，返回图片路径
    @PostMapping("/UploadImag")
    public Res<?> UploadImag(MultipartFile file) throws Exception {
        String FileName = file.getOriginalFilename();
        String objetFileName = UUID.randomUUID().toString() + FileName.substring(FileName.lastIndexOf("."));
        String url = OssFile.CreatOss(objetFileName , file.getInputStream());
        return Res.success(url , "上传成功");
    }
}
